#!/bin/bash

DB_NAME="tanye_db"

BACKUP_DIR="/backup"

DATE=$(date +%Y%m%d)

BACKUP_FILE="${BACKUP_DIR}/${DB_NAME}-${DATE}.sql"

if [ ! -d "$BACKUP_DIR" ]; then

    mkdir -p "$BACKUP_DIR"

    echo "mkdir: $BACKUP_DIR"

fi

mysqldump "$DB_NAME" > "$BACKUP_FILE"

if [ $? -eq 0 ]; then

    echo "success!:$BACKUP_FILE"

else

    echo "Failure!"

fi
